#SET集合
#1.不允许重复2.内容无序
my_set = {"lh","a","b","c"}
#添加元素
my_set.add("a")
print(my_set)

#移除元素
my_set.remove("c")
print(my_set)

#取出元素
element = my_set.pop()
#随机取
print(f"取出元素:{element},取出后为{my_set}")

#清空集合
my_set.clear()

#取两个集合的差集
set1 = {1,2,3}
set2 = {2,3,4}
set3 = set1.difference(set2)
print(set3)

#消除两个集合的差集,消除集合1里面和集合2相同的元素
set1.difference_update(set2)
print(set1,set2)

#合并
set4 = set1.union(set2)
print(set4)

#len

#遍历
#集合不支持下标索引
for x in set2:
    print(x)


my_list = [1,2,3,4]
my_set1 = set()
for element in my_list:
    my_set1.add(element)


print(my_set1)